<?php 

use Da\QrCode\Label;
use Da\QrCode\QrCode;

// 加入文字
$label = (new Label('JSPC01 -上海大丸'))
    // ->useFont(__DIR__ . '/../resources/fonts/monsterrat.otf')
    ->updateFontSize(14);

$qrCode = (new QrCode('This is my text'))
    ->setSize(250)
    ->setMargin(10)
    ->useForegroundColor(51, 153, 255)
    ->setLabel($label);

// now we can display the qrcode in many ways
// saving the result to a file:

// 生成二维码文件
// $qrCode->writeFile(__DIR__ . '/code.png'); // writer defaults to PNG when none is specified

// display directly to the browser 
header('Content-Type: '.$qrCode->getContentType());
// echo $qrCode->writeString();

?> 

<img src="<?= $qrCode->writeDataUri() ?>" alt="">